(function() {
let row=document.querySelector('.row')
let al=""
fetch('http://chst.vip:1234/api/getindexmenu')
.then(body => body.json())
.then(res => {
     console.log(res)
    res.result.forEach(item => {
        let regExp = /^<[^<]+\s+src="([^''""]*)"/
       let r=item.img.match(regExp)
       console.log(r)
       let imgUrl = "http://chst.vip:8081/mmb/" + r[1];
    //   console.log(item)
    al+=`
    <div class="col-xs-3">
    <a href="./../html/${item.titlehref}">
   <span> 
    <img src="${imgUrl}"  alt="${item.name}
    </span>
    <p class="in_name">${item.name}</p>
    </a>
    </div>`
    })
    row.innerHTML=al;
    let isShow = true;
    $('.row>div').eq(7).on("click",function(){
         if (isShow) {
             $(this).parent().stop().animate({ height: '2.55rem' }, 500);
            isShow = false;
        } else {
            $(this).parent().stop().animate({ height: '1.68rem' }, 500);
            isShow = true;
        }

    })
})
let uu=document.querySelector('ul')
fetch('http://chst.vip:1234/api/getmoneyctrl')
.then(body => body.json())
.then(res => {
    let result = res.result;
    
    let discStr = '';
    result.forEach(item => {
    let regExp = /(?<=imgurl=)[^'"]*/;
    let r=item.productImgSm.match(regExp)
        discStr += `
 <li class="date-product>
         <a href="./../html/discount.html?productid=${item.productId}">
            <div class="imgico">
            <img src=${r[0]} alt="">
                </div>
                <div class="info">
                     <h3>${item.productName}</h3>
                     <span class="category">¥ ${item.productPinkage}</span>
                    <div class="desc">
                         <span class="times">${item.productFrom} | ${item.productTime}</span>
                             <div class="review">
                                   <i></i>
                                        <span>${item.productComCount}</span>
                                    </div>
                                </div>
                            </div>
                        </a>
                    </li>
                `
    });
    uu.innerHTML=discStr
});
$('.product').on('click','li',function(){
    location.href='../html/indexproduct.html?productid=' + $(this).attr('date-productId')
    console.log(productid);
})

})()

